package com.hadoop.mr.amiudake.flow;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class FlowDriver {
	public static String NAME_NODE_URL = "hdfs://192.168.186.6:9000";

	public static void main(String[] args) throws Exception {
		try {

			Configuration conf = new Configuration();
			Job job = Job.getInstance(conf, "flow");
			job.setNumReduceTasks(4);
			job.setJarByClass(FlowDriver.class);
			job.setMapperClass(FlowMapper.class);
			job.setReducerClass(FlowReduce.class);

			job.setPartitionerClass(FlowPartitioner.class);

			job.setMapOutputKeyClass(Text.class);
			job.setMapOutputValueClass(FlowBean.class);

			job.setOutputKeyClass(Text.class);
			job.setOutputValueClass(FlowBean.class);

			FileInputFormat.setInputPaths(job, new Path(NAME_NODE_URL + "/mr/flow.txt"));
			FileOutputFormat.setOutputPath(job, new Path(NAME_NODE_URL + "/mr/result/flow"));
			job.waitForCompletion(true);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
